survey$income <- factor(dplyr::recode(survey$F6,
`1` = "Under $5,000",
`2` = "$5,000 to $6,999",
`3` = "$7,000 to $9,999",
`4` = "$10,000 to $14,999",
`5` = "$15,000 to $19,999",
`6` = "$20,000 to $24,999",
`7` = "$25,000 to $34,999",
`8` = "$35,000 and over",
`9` = "Not sure/refused"))
summary(survey$income)
# age
survey$age <- factor(dplyr::recode(survey$F3,
`1` = "18 to 20",
`2` = "21 to 24",
`3` = "25 to 29",
`4` = "30 to 34",
`5` = "35 to 39",
`6` = "40 to 49",
`7` = "50 to 64",
`8` = "65 and over",
`9` = "Refused"))
summary(survey$age)
# race
survey$race <- factor(dplyr::recode(survey$F7,
`1` = "White",
`2` = "Black",
`3` = "Oriental",
`4` = "Spanish-American (Puerto Rican, Mexican-American, etc.)",
`5` = "Other (SPECIFY)"))
summary(survey$race)
# politics (party)
survey$party <- factor(dplyr::recode(survey$Q24C,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other (vol.)",
`5` = "Not sure"))
# politics (ideology)
survey$ideology <- NA
# gender
survey$gender <- factor(dplyr::recode(survey$F8,
`1` = "Male",
`2` = "Female"))
# religion
survey$religion <- NA
# subset
survey_2829 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_2829)
saveRDS(survey_2829, file = "survey_2829-black.rds")
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/Harris 1978 Political Issues and Congressional Election Survey, study no. P3849")
library(tidyr)
library(car)
survey <- read.table("harris_p3849_spss.tab", header = TRUE)
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <- 3849
# study year (year)
survey$year <- 1978
# geographic data (urban)
# survey$urban <- car::recode(survey$S13, "'Central City' = 'Urban'; 'Town' = 'Rural';
# 'Suburb' = 'Suburban'; 'Rural' = 'Rural'")
survey$urban <- NA
# geographic data (region)
# survey$region <- survey$S11
# levels(survey$region) <- list(East=c("East_(1)", "East_(2)"), Midwest=c("Midwest_(5)", "Midwest_(6)"),
#  South=c("South_(3)", "South_(4)"),
#  West=c("West_(7)", "West_(8)"))
survey$region <- NA
# respondent head of household (hh)
survey$hh <- NA
# survey$hh <- car::recode(survey$F1, "c('Male head', 'Female head (no male head)') = 'Yes';
# c('Wife', 'Son', 'Daughter', 'Other (specify)') = 'No'; else = NA")
# increasing inequality (inequality)
class(survey$Q7_2)
survey$inequality <- car::recode(survey$Q7_2, "1 = 'Feel'; 2 = 'Don t feel'; 3 = 'Not sure'")
survey$inequality <- as.factor(survey$inequality)
# inequality variable (inequality.variable)
survey$inequality.variable <- 1
# union (union.self)
survey$union.self <- car::recode(survey$F5_1, "0 = 'No'; 1 = 'Yes'; else = NA")
survey$union.self <- as.factor(survey$union.self)
# union (union.other)
survey$union.other <- car::recode(survey$F5_2, "0 = 'No'; 1 = 'Yes'; else = NA")
survey$union.other <- as.factor(survey$union.other)
# employment (employed)
survey$employed <- survey$F1A
# occupation
survey$occupation <- survey$F1B
# household size (hhsize)
survey$hhsize <- NA
# education (educ)
survey$educ <- survey$F4
survey$educ <- car::recode(survey$educ, "c(1, 2, 3, 4) = 'Less than high school';
5 = 'High school graduate';
c(6, 7) = 'Some college';
8 = 'College graduate';
9 = 'Post graduate';
else = 'NA'")
survey$educ <- factor(survey$educ, levels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
labels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
ordered = TRUE)
# household income (income)
survey$income <- survey$F6
# age
survey$age <- survey$F3
# race
survey$race <- survey$F8
# politics (party)
survey$party <- survey$Q1E
# politics (ideology)
survey$ideology <- survey$Q1H
# gender
survey$gender <- survey$F9
# religion
survey$religion <- survey$F7
# subset
survey_3849 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_3849)
survey <- read.table("harris_p3849_spss.tab", header = TRUE)
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <- 3849
# study year (year)
survey$year <- 1978
# geographic data (urban)
# survey$urban <- car::recode(survey$S13, "'Central City' = 'Urban'; 'Town' = 'Rural';
# 'Suburb' = 'Suburban'; 'Rural' = 'Rural'")
survey$urban <- NA
# geographic data (region)
# survey$region <- survey$S11
# levels(survey$region) <-
survey$region <- NA
survey$hh <- NA
class(survey$Q7_2)
survey$inequality <- car::recode(survey$Q7_2, "1 = 'Feel'; 2 = 'Don t feel'; 3 = 'Not sure'")
survey$inequality <- as.factor(survey$inequality)
survey$inequality.variable <- 1
survey$union.self <-   car::recode(survey$F5_1, "0 = 'No'; 1 = 'Yes'; else = NA")
survey$union.other <- car::recode(survey$F5_2, "0 = 'No'; 1 = 'Yes'; else = NA")
summary(survey$union.self)
table(survey$union.self)
table(survey$union.other)
table(survey$union.self)[survey$F5_4 == 1]
table(survey$F5_4)
table(survey$union.self[survey$F5_4 == 1])
table(survey$union.other[survey$F5_4 == 1])
survey$union.self[survey$F5_4 == 1] <- NA
survey$union.other[survey$F5_4 == 1] <- NA
survey$union.other <- factor(survey$union.other)
survey$union.self <- factor(survey$union.self)
summary(survey$union.other)
summary(survey$union.self)
survey$employed <- factor(dplyr::recode(survey$F1A,
`1` = "Hourly wage worker",
`2` = "Salaried",
`3` = "Self-employed",
`4` = "Retired",
`5` = "Unemployed",
`6` = "Student",
`7` = "Military service",
`8` = "Housewife",
`9` = "Disabled",
`10` = "Other (SPECIFY)"))
summary(survey$employed)
survey$occupation <- factor(dplyr::recode(survey$F1B,
`1` = "Professional",
`2` = "Manager, official",
`3` = "Proprietor (small business)",
`4` = "Clerical worker",
`5` = "Sales worker",
`6` = "Skilled craftsman, foreman",
`7` = "Operative, unskilled laborer (except farm)",
`8` = "Service worker",
`9` = "Farmer, farm manager, farm laborer",
`10` = "Other (SPECIFY)"))
summary(survey$occupation)
survey$race <- factor(dplyr::recode(survey$F8,
`1` = "White",
`2` = "Black",
`3` = "Oriental",
`4` = "Spanish-American (Puerto Rican, Mexican-American, etc.)",
`5` = "Other (SPECIFY)"))
summary(survey$race)
survey$party <- factor(dplyr::recode(survey$Q1E,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other (vol.)",
`5` = "Not sure"))
summary(survey$party)
survey$party <- factor(dplyr::recode(survey$Q1E,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other",
`5` = "Not sure"))
summary(survey$party)
survey$ideology <- factor(dplyr::recode(survey$Q1H,
`1` = "Conservative",
`2` = "Middle-of-the-road",
`3` = "Liberal",
`4` = "Radical",
`5` = "Not sure"))
summary(survey$ideology)
survey$gender <- factor(dplyr::recode(survey$F9,
`1` = "Male",
`2` = "Female"))
summary(survey$gender)
survey$religion <- factor(dplyr::recode(survey$F7,
`1` = "Protestant",
`2` = "Catholic",
`3` = "Jewish",
`4` = "Other (SPECIFY)",
`5` = "None",
`6` = "Not sure"))
survey <- read.table("harris_p3849_spss.tab", header = TRUE)
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <- 3849
# study year (year)
survey$year <- 1978
# geographic data (urban)
# survey$urban <- car::recode(survey$S13, "'Central City' = 'Urban'; 'Town' = 'Rural';
# 'Suburb' = 'Suburban'; 'Rural' = 'Rural'")
survey$urban <- NA
# geographic data (region)
# survey$region <- survey$S11
# levels(survey$region) <- list(East=c("East_(1)", "East_(2)"), Midwest=c("Midwest_(5)", "Midwest_(6)"),
#  South=c("South_(3)", "South_(4)"),
#  West=c("West_(7)", "West_(8)"))
survey$region <- NA
# respondent head of household (hh)
survey$hh <- NA
# survey$hh <- car::recode(survey$F1, "c('Male head', 'Female head (no male head)') = 'Yes';
# c('Wife', 'Son', 'Daughter', 'Other (specify)') = 'No'; else = NA")
# increasing inequality (inequality)
class(survey$Q7_2)
survey$inequality <- car::recode(survey$Q7_2, "1 = 'Feel'; 2 = 'Don t feel'; 3 = 'Not sure'")
survey$inequality <- as.factor(survey$inequality)
# inequality variable (inequality.variable)
survey$inequality.variable <- 1
# union (union.self) union other
survey$union.self <-   car::recode(survey$F5_1, "0 = 'No'; 1 = 'Yes'; else = NA")
survey$union.other <- car::recode(survey$F5_2, "0 = 'No'; 1 = 'Yes'; else = NA")
table(survey$union.self[survey$F5_4 == 1])
table(survey$union.other[survey$F5_4 == 1])
survey$union.self[survey$F5_4 == 1] <- NA
survey$union.other[survey$F5_4 == 1] <- NA
survey$union.other <- factor(survey$union.other)
survey$union.self <- factor(survey$union.self)
summary(survey$union.other)
summary(survey$union.self)
# employment (employed)
survey$employed <- factor(dplyr::recode(survey$F1A,
`1` = "Hourly wage worker",
`2` = "Salaried",
`3` = "Self-employed",
`4` = "Retired",
`5` = "Unemployed",
`6` = "Student",
`7` = "Military service",
`8` = "Housewife",
`9` = "Disabled",
`10` = "Other (SPECIFY)"))
summary(survey$employed)
# occupation
survey$occupation <- factor(dplyr::recode(survey$F1B,
`1` = "Professional",
`2` = "Manager, official",
`3` = "Proprietor (small business)",
`4` = "Clerical worker",
`5` = "Sales worker",
`6` = "Skilled craftsman, foreman",
`7` = "Operative, unskilled laborer (except farm)",
`8` = "Service worker",
`9` = "Farmer, farm manager, farm laborer",
`10` = "Other (SPECIFY)"))
summary(survey$occupation)
# household size (hhsize)
survey$hhsize <- NA
# education (educ)
survey$educ <- survey$F4
survey$educ <- car::recode(survey$educ, "c(1, 2, 3, 4) = 'Less than high school';
5 = 'High school graduate';
c(6, 7) = 'Some college';
8 = 'College graduate';
9 = 'Post graduate';
else = 'NA'")
survey$educ <- factor(survey$educ, levels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
labels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
ordered = TRUE)
# household income (income)
survey$income <- factor(dplyr::recode(survey$F6,
`1` = "Under $5,000",
`2` = "$5,000 to $6,999",
`3` = "$7,000 to $9,999",
`4` = "$10,000 to $14,999",
`5` = "$15,000 to $19,999",
`6` = "$20,000 to $24,999",
`7` = "$25,000 to $34,999",
`8` = "$35,000 and over",
`9` = "Not sure/refused"))
summary(survey$income)
# age
survey$age <- factor(dplyr::recode(survey$F3,
`1` = "18 to 20",
`2` = "21 to 24",
`3` = "25 to 29",
`4` = "30 to 34",
`5` = "35 to 39",
`6` = "40 to 49",
`7` = "50 to 64",
`8` = "65 and over",
`9` = "Refused"))
summary(survey$age)
# race
survey$race <- factor(dplyr::recode(survey$F8,
`1` = "White",
`2` = "Black",
`3` = "Oriental",
`4` = "Spanish-American (Puerto Rican, Mexican-American, etc.)",
`5` = "Other (SPECIFY)"))
summary(survey$race)
# politics (party)
survey$party <- factor(dplyr::recode(survey$Q1E,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other",
`5` = "Not sure"))
summary(survey$party)
# politics (ideology)
survey$ideology <- factor(dplyr::recode(survey$Q1H,
`1` = "Conservative",
`2` = "Middle-of-the-road",
`3` = "Liberal",
`4` = "Radical",
`5` = "Not sure"))
summary(survey$ideology)
# gender
survey$gender <- factor(dplyr::recode(survey$F9,
`1` = "Male",
`2` = "Female"))
summary(survey$gender)
# religion
survey$religion <- factor(dplyr::recode(survey$F7,
`1` = "Protestant",
`2` = "Catholic",
`3` = "Jewish",
`4` = "Other (SPECIFY)",
`5` = "None",
`6` = "Not sure"))
# subset
survey_3849 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_3849)
saveRDS(survey_3849, file = "survey_3849.rds")
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/Harris 1979 Vietnam War Veterans Survey, study no. 792801")
library(dplyr)
library(tidyr)
library(car)
# loading vets
survey <- read.table("harris_s792801_veterans_spss.tab", header = TRUE)
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <- 792801
# study year (year)
survey$year <- 1979
# geographic data (urban)
# survey$urban <- car::recode(survey$S13, "'Central City' = 'Urban'; 'Town' = 'Rural';
#                          'Suburb' = 'Suburban'; 'Rural' = 'Rural'")
survey$urban <- NA
# geographic data (region)
# survey$region <- survey$S11
# levels(survey$region) <- list(East=c("East_(1)", "East_(2)"), Midwest=c("Midwest_(5)", "Midwest_(6)"),
#                              South=c("South_(3)", "South_(4)"),
#                              West=c("West_(7)", "West_(8)"))
survey$region <- NA
# respondent head of household (hh)
survey$hh <- as.factor(car::recode(survey$F9A, "c(1, 3) = 'Yes'; 2 = 'No'; 4 = 'Not sure'; else = NA"))
# increasing inequality (inequality)
survey$inequality <- as.factor(car::recode(survey$Q36_B, "1 = 'Feel'; 2 = 'Don t feel'; 3 = 'Not sure'; else = NA"))
# inequality variable (inequality.variable)
survey$inequality.variable <- 1
# union (union.self)
survey$union.self <- as.factor(car::recode(survey$F3A, "1 = 'Yes'; 2 = 'No'; 3 = 'Not sure'; else = NA"))
# union (union.other)
survey$union.other <- as.factor(car::recode(survey$F3B, "1 = 'Yes'; 2 = 'No'; 3 = 'Not sure'; else = NA"))
# employment (employed)
survey$employed <- survey$F10A
# occupation
# survey$occupation <- survey$F10B  ##cannot find this variable
survey$occupation <- NA
# household size (hhsize)
survey$hhsize <- survey$F11A
# education (educ)
survey$educ <- car::recode(survey$F4C, "c(1, 2, 3, 4) = 'Less than high school';
5 = 'High school graduate';
c(6, 7, 10) = 'Some college';
8 = 'College graduate';
9 = 'Post graduate';
else = 'NA'")
survey$educ <- factor(survey$educ, levels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
labels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
ordered = TRUE)
# household income (income)
survey$income <- survey$F13
# age
survey$age <- survey$F2A
# race
survey$race <- survey$F14
# politics (party)
# survey$party <- survey$P6B
survey$party <- NA
# politics (ideology)
# survey$ideology <- survey$P7A
survey$ideology <- NA
# gender
survey$gender <- survey$F15
# religion
# survey$religion <- survey$F8A
survey$religion <- NA
# subset
survey_vet <- survey[ ,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
# repeat for public dataset
survey <- read.table("harris_s792801_public_spss.tab", header = TRUE)
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <- 792801
# study year (year)
survey$year <- 1979
# geographic data (urban)
# survey$urban <- car::recode(survey$S13, "'Central City' = 'Urban'; 'Town' = 'Rural';
#                          'Suburb' = 'Suburban'; 'Rural' = 'Rural'")
survey$urban <- NA
# geographic data (region)
# survey$region <- survey$S11
# levels(survey$region) <- list(East=c("East_(1)", "East_(2)"), Midwest=c("Midwest_(5)", "Midwest_(6)"),
#                              South=c("South_(3)", "South_(4)"),
#                              West=c("West_(7)", "West_(8)"))
survey$region <- NA
# respondent head of household (hh)
survey$hh <- as.factor(car::recode(survey$F6A, "c(1, 3) = 'Yes'; 2 = 'No'; 4 = 'Not sure'; else = NA"))
# increasing inequality (inequality)
survey$inequality <- as.factor(car::recode(survey$Q19_B, "1 = 'Feel'; 2 = 'Don t feel'; 3 = 'Not sure'; else = NA"))
# inequality variable (inequality.variable)
survey$inequality.variable <- 1
# union (union.self)
survey$union.self <- as.factor(car::recode(survey$F3A, "1 = 'Yes'; 2 = 'No'; 3 = 'Not sure'; else = NA"))
# union (union.other)
survey$union.other <- as.factor(car::recode(survey$F3B, "1 = 'Yes'; 2 = 'No'; 3 = 'Not sure'; else = NA"))
# employment (employed)
survey$employed <- survey$F7A
# occupation
# survey$occupation <- survey$F7B  ## cannot find this variable
survey$occupation <- NA
# household size (hhsize)
survey$hhsize <- survey$F8A
# education (educ)
survey$educ <- car::recode(survey$F4, "c(1, 2, 3, 4) = 'Less than high school';
5 = 'High school graduate';
c(6, 7, 10) = 'Some college';
8 = 'College graduate';
9 = 'Post graduate';
else = 'NA'")
survey$educ <- factor(survey$educ, levels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
labels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
ordered = TRUE)
# household income (income)
survey$income <- survey$F9
# age
survey$age <- survey$F2
# race
survey$race <- survey$F10
# politics (party)
# survey$party <- survey$P6B
survey$party <- NA
# politics (ideology)
# survey$ideology <- survey$P7A
survey$ideology <- NA
# gender
survey$gender <- survey$F11
# religion
# survey$religion <- survey$F8A
survey$religion <- NA
# subset
survey_pub <- survey[ ,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
# combine the two
survey_792801 <- rbind(survey_vet, survey_pub)
# recode pid
survey_792801$pid <- c(1:nrow(survey_792801))
summary(survey_792801)
